package com.tomecode.tools.maven.settings.gui;

import java.awt.BorderLayout;
import java.awt.Dimension;

import javax.swing.JPanel;
import javax.swing.JProgressBar;

import com.tomecode.util.gui.Dialog;
import com.tomecode.util.gui.HideNotifiListener;
import com.tomecode.util.gui.PanelFactory;

/**
 * Frm loading
 * 
 * @author Frastia Tomas
 * 
 */
public final class FrmLoading extends Dialog {

	private static final long serialVersionUID = -6919614346211693928L;

	private final JProgressBar progressBar;

	public FrmLoading() {
		super(null, "Loading...", 400, 120, false, true, false, true);
		progressBar = new JProgressBar(0, 50);
		progressBar.setPreferredSize(new Dimension(100, 10));
		progressBar.setIndeterminate(true);

		panelRoot.add(PanelFactory.createBorderLayout(PanelFactory.wrapByBorderLayout(progressBar, BorderLayout.NORTH), 10, 15, 10, 15), BorderLayout.CENTER);

		JPanel pButton = PanelFactory.createButtonsPanelCenter();
		pButton.add(buttonCancel);
		panelRoot.add(pButton, BorderLayout.SOUTH);
	}

	public FrmLoading(String title) {
		this();
		setTitle(title);
	}

	public static final void showMe(final HideNotifiListener listener) {
		javax.swing.SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				new FrmLoading().addHideListeners(listener).setVisible(true);
			}
		});
	}

	public final void showFrm(final HideNotifiListener listener) {
		javax.swing.SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				addHideListeners(listener);
				setVisible(true);
			}
		});
	}

}
